import http from '@/utils/http'

export const loginApi = async (data) => {
  const url = '/api/userlogin'
  return http.post(url, data)
}

//获取侧边栏菜单项
export const getListApi = async (data) => {
  const url = '/api/menulist'
  let obj={params:{istree:data}}
  return http.get(url,obj)
}

//获取登录角色的权限
export const getPermissApi = async (id) => {
  const url = '/api/roleinfo'
  let obj={params:{id}}
  return http.get(url,obj)
}

export const getPermiss =function (arr1,arr2) {
  for(let i = 0;i<arr1.length;i++){
    let flag=false
    for(let j=0;j<arr2.length;j++){
      if(arr1[i].id==arr2[j]){
        flag=true
      }
    }
    if(!flag){
      arr1.splice(i,1)
      i--
    }
  }
  /* for(let k=0;k<arr1.length;k++){
    if(arr1[k].children!=undefined){
      getPermiss(arr1[k].children,arr2)
    }
  } */
  return arr1
}